Skip to content

Conversation

@yusufnasserdev
Copy link
Collaborator

No description provided.

This commit refactors the way `SnackBarController` is accessed and used within composables.

- Introduces `rememberSnackBarController()` composable function in the `designSystem` module to retrieve the `LocalSnackbarController` instance.
- Updates `ViewItemsScreen`, `BookmarkSheet`, and `ListScreen` in the `presentation` module to use `rememberSnackBarController()` instead of directly accessing `LocalSnackbarController.current`.
- Removes the explicit `icon` parameter from `snackBarController.showMessage` calls as the icons are now likely handled internally by the `SnackBarController` based on the `SnackBarType`.
- Changes `LocalSnackbarController` from `staticCompositionLocalOf` to `compositionLocalOf` for potentially better performance characteristics in some scenarios.
This commit introduces several enhancements to the SnackBar functionality within the design system:

- Refactors `SnackBarController` and introduces `SnackBarData` for better state management and customization of SnackBar messages, types, and durations.
- Implements `SnackBarControllerImpl` to handle the display logic and queuing of SnackBar messages using coroutines.
- Adds `SnackBarState` to manage the visibility and data of the SnackBar.
- Introduces `SnackbarDuration` enum to define standard display times for SnackBars (Short, Medium, Extensive, Indefinite).
- Defines default icons for `Success` and `Error` `SnackBarType`s.
- Updates `ScaffoldWithSnackBar` to use the new `SnackBarControllerImpl` and `SnackBarData`, and collects state using `collectAsStateWithLifecycle`.
- Introduces `SnackBarAnimationConfig` to allow customization of SnackBar enter and exit animations and duration.
- Renames `CustomSnackBarUI` to `DefaultSnackBar` for clarity.
- Simplifies icon handling in `DefaultSnackBar` by using `data.snackBarType.getDefaultIcon().painter`.
This commit updates the SnackBar implementation across the app.

- Replaced `showMessage` with `showSnackBar` and wrapped parameters in `SnackBarData` class for better organization in `ViewItemsScreen.kt`, `BookmarkSheet.kt`, and `ListScreen.kt`.
- Renamed `CustomSnackBarUI` to `DefaultSnackBar` in `NavHostGraph.kt`.
- Simplified `rememberSnackBarController()` in `LocalSnackbarController.kt`.
This commit refactors the error handling in the Login screen.
- Removes the `SnackBarAnimation` composable and replaces it with the `SnackBarController` from the design system to display error messages.
- Updates `LoginViewModel` to set a generic `ErrorState.RequestFailed` without a specific message, as the message is now handled by the UI.
This commit refactors the snackbar visibility logic in `ScaffoldWithSnackBar.kt` and `SnackBarControllerImpl.kt`.

In `ScaffoldWithSnackBar.kt`:
- The `AnimatedVisibility` composable now wraps the `snackBar(data)` call directly.
- The null check for `currentSnackbarData.data` is now performed inside the `AnimatedVisibility` content.

In `SnackBarControllerImpl.kt`:
- The `processNextMessage` function now uses a `queueMutex` to safely remove the next message from the `messageQueue`. This prevents potential race conditions when accessing the queue.
- If the queue is empty, the coroutine launched to process the message will now return early.
This commit refactors the `MovieDetailsScreen` to use the `rememberSnackBarController` and `SnackBarData` from the design system for displaying success and failure messages for ratings. This replaces the previous `SnackBarAnimation` composable.

Key changes:
- Integrated `rememberSnackBarController` to manage SnackBar display.
- Used `SnackBarData` with `SnackBarType.Success` and `SnackBarType.Error` for rating feedback.
- Removed the custom `SnackBarAnimation` composable.
- Utilized the `.string` extension function for cleaner string resource access.
This commit updates the rating success/failure snackbar in `EpisodeDetailScreen.kt` to use the `SnackBarController` and `SnackBarData` from the design system, replacing the custom `SnackBarAnimation`.

This change standardizes the snackbar implementation and leverages the design system's snackbar types (Success/Error).
This commit replaces the custom `SnackBarAnimation` with the `rememberSnackBarController` and `SnackBarData` from the design system for displaying success and failure messages for ratings.

- Updated `TvShowDetailScreen.kt` to use `rememberSnackBarController` to manage SnackBar display.
- Replaced `SnackBarAnimation` calls with `snackBarController.showSnackBar()` using `SnackBarData`.
- Set `SnackBarType.Error` for both success and failure messages, which seems like a potential bug that might need further attention.
This commit removes the `SnackBarAnimation.kt` file as it is no longer needed. The functionality provided by this composable can be achieved using the snackBarController
This commit updates the `AppNavBar` composable:
- Simplifies screen width calculation by directly using `LocalConfiguration.current.screenWidthDp.dp`.
This commit renames the `SnackbarDuration.Short` enum value to `SnackbarDuration.Brief` in `SnackBarController.kt`. The corresponding millisecond value remains unchanged at 1500.
@london-bot
Copy link
Contributor

london-bot bot commented Aug 30, 2025

[London Bot] Metrics Update Status

📊 PR metrics successfully updated for event: closed.

@london-bot
Copy link
Contributor

london-bot bot commented Aug 30, 2025

[London Bot] Auto-update Status

✅ Branch successfully updated from develop.

@yusufnasserdev yusufnasserdev self-assigned this Aug 30, 2025
@yusufnasserdev yusufnasserdev requested review from a team August 30, 2025 11:25
This commit removes the `Context` dependency from `LoginViewModelTest` after eliminating its usage for fetching string resources. The string resources `R.string.login_failed` and `R.string.guest_login_failed` were previously fetched using the `Context` but are no longer used by the ViewModel.
@github-actions
Copy link

Code Coverage Summary

File Coverage [53.49%]
presentation/src/main/java/com/london/presentation/feature/authentication/login/LoginViewModel.kt 53.49%
Total Project Coverage 60.66%

@yusufnasserdev yusufnasserdev merged commit d57f2bb into develop Sep 2, 2025
8 checks passed
@yusufnasserdev yusufnasserdev deleted the refactor/snackbar-manager branch September 2, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant